package io.zhaocy.springbootenable.selector;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.stereotype.Component;

/**
 * Description:
 *
 * @Author: genezhao
 * @Date: 2018-07-13
 */
@Component
public class MyImportSelector implements ImportSelector {

    private final Logger logger = LoggerFactory.getLogger(MyImportSelector.class);

    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {
        System.out.println(annotationMetadata.getAnnotationAttributes(EnableLogInfo.class.getName()));

        if (annotationMetadata.getAnnotationAttributes(EnableLogInfo.class.getName() )!=null
                && annotationMetadata.getAnnotationAttributes(EnableLogInfo.class.getName()).toString().contains("onlySale")) {
            logger.info(Sales.class.getName());
            return new String[]{Sales.class.getName()};
        }
        return new String[]{Market.class.getName(), Sales.class.getName()};
    }
}
